import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login'
import Main from '@/components/Main';
import Artcile from '@/components/Artcile';
import HelloWorld from '@/components/HelloWorld'
import Commun_New from '@/components/SY_Main/commun_new'
import Commun_Hot from '@/components/SY_Main/commun_hot'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Main',
    component: Main,
    children: [
      {
        path: '/SY_Main',
        name:'commun_new',
        component: Commun_New
      },
      {
        path: '/SY_Main',
        name:'commun_hot',
        component: Commun_Hot
      }
    ]
  },
  {
    path: '/Login',
    name: 'Login',
    component: Login
  },
  {
    path: '/HelloWorld',
    name: 'HelloWorld',
    component: HelloWorld,
    children:[
      {
        path: '/artcile',
        name:'Artcile',
        component: Artcile
      }
    ]
  },
]

const router = new VueRouter({
  routes
})

// 前端路由守卫判断是否登录
// router.beforeEach((to,from,next)=>{
//   if(to.path==='/Login')
//   {
//     next();
//   }
//   if(!window.sessionStorage.getItem('token') || window.sessionStorage.getItem('token')==null || window.sessionStorage.getItem('token')===''|| window.sessionStorage.getItem('token')===undefined)
//   {
//     next('/Login');
//   }
//   next();
// })

export default router
